"use strict";

/**
 * @name server
 * @param string sid 服务器ID
 * 获取服务器信息
 */

exports.start =  function(){
    let sid = this.get('sid','array');
    let port = this.get('port','int');

    if(!sid || sid.length < 1){
        return this.error('args empty');
    }   



    let keys = ['name','status','time','local'];
    let server = this.model.branch('server',this.branch);

    return server.get(sid,keys).then(rows=>{
        if(port){
            let ip = String(this.req.ip).replace("::ffff:",'');
            let local = ['http://',ip,":",port].join('');
            server.set(sid,'local',local);
        }
        return rows;
    });
}

